package com.twu.biblioteca.command;

import com.twu.biblioteca.UsersManager;

/**
 * Created with IntelliJ IDEA.
 * User: twer
 * Date: 6/1/13
 * Time: 8:21 AM
 * To change this template use File | Settings | File Templates.
 */
public class CommandProxy implements Command {

    private Command commandObj;
    private UsersManager usersManager;

    public CommandProxy(Command commandObj, UsersManager usersManager){

        this.commandObj = commandObj;
        this.usersManager = usersManager;
    }

    @Override
    public String execute() {
        if(usersManager.authenticate(commandObj))
            return commandObj.execute();

        return "Authentication failed";
    }
}
